using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CodePlex.SpaceBlock.FS;
using CodePlex.Resourceful;
using CodePlex.Resourceful.Amazon.S3;
using CodePlex.Resourceful.Microsoft.Azure;

namespace CodePlex.SpaceBlock.UI.Controls.Explore
{
    public partial class AzureContainerAccessEditorForm : CodePlex.SpaceBlock.UI.Controls.BaseForm
    {

        private AzureBlobStorageConnection _connection;
        private string _containerName;
        

        public AzureContainerAccessEditorForm()
        {
            InitializeComponent();

            this.MinimumSize = this.Size;

            _descriptionLabel.Text = Properties.Messages.AzureContainerAccess_Description;

            _isPublicCheck.CheckedChanged += delegate
            {
                
                _saveButton.Enabled = true;
            };
           
            this.SetupDialogWork(_cancelButton, _saveButton, delegate
            {
                bool isPublic = _isPublicCheck.Checked;

                _connection.SetContainerACL(_containerName, isPublic);
                
                return true;
            });

        }

        public void Initialize(AzureBlobStorageFileSystem absfs, string containerName)
        {
            _connection = absfs.Connection;
            _containerName = containerName;

            this.Text = string.Format(Properties.Messages.AzureContainerAccess_Title, _containerName);

            bool isPublic = _connection.GetContainerACL(_containerName);

            _isPublicCheck.Checked = isPublic;
      

           _saveButton.Enabled = false;

         

        }

       
      

    }
}

